
/****** Object:  Table [dbo].[CalendarRange]    Script Date: 6/29/2013 8:39:59 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[CalendarRange](
	[CalendarRangeId] [int] IDENTITY(1,1) NOT NULL,
	[DateFrom] [date] NOT NULL,
	[DateTo] [date] NOT NULL,
 CONSTRAINT [PK_CalendarRange] PRIMARY KEY CLUSTERED 
(
	[CalendarRangeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


/****** Object:  Table [dbo].[ContactInfo]    Script Date: 6/29/2013 8:40:12 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ContactInfo](
	[ContactInfoId] [int] IDENTITY(1,1) NOT NULL,
	[MobileNumber] [nvarchar](250) NULL,
	[AddressLine1] [nvarchar](500) NOT NULL,
	[City] [nvarchar](500) NOT NULL,
	[PostCode] [nvarchar](10) NOT NULL,
	[State] [nvarchar](3) NOT NULL,
	[Email] [nvarchar](250) NOT NULL,
 CONSTRAINT [PK_ContactInfo] PRIMARY KEY CLUSTERED 
(
	[ContactInfoId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


/****** Object:  Table [dbo].[HouseSitter]    Script Date: 6/29/2013 8:40:46 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[HouseSitter](
	[HouseSitterId] [int] IDENTITY(1,1) NOT NULL,
	[IsCouple] [bit] NOT NULL,
	[SelfDescription] [nvarchar](max) NULL,
	[LikesDogs] [bit] NULL,
	[LikesCats] [bit] NULL,
	[Children] [int] NULL,
	[HouseTypePreference] [nvarchar](250) NULL,
	[LocationPreference] [nvarchar](500) NOT NULL,
	[ContactInfoId] [int] NOT NULL,
	[IsWoman] [bit] NOT NULL,
	[BirthDate] [date] NOT NULL,
	[UserId] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_HouseSitter] PRIMARY KEY CLUSTERED 
(
	[HouseSitterId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[HouseSitter]  WITH CHECK ADD  CONSTRAINT [FK_HouseSitter_ContactInfo] FOREIGN KEY([HouseSitterId])
REFERENCES [dbo].[ContactInfo] ([ContactInfoId])
GO

ALTER TABLE [dbo].[HouseSitter] CHECK CONSTRAINT [FK_HouseSitter_ContactInfo]
GO

ALTER TABLE [dbo].[HouseSitter]  WITH CHECK ADD  CONSTRAINT [FK_HouseSitter_Users] FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO

ALTER TABLE [dbo].[HouseSitter] CHECK CONSTRAINT [FK_HouseSitter_Users]
GO


/****** Object:  Table [dbo].[Calendar]    Script Date: 6/29/2013 8:39:42 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Calendar](
	[CalendarId] [int] IDENTITY(1,1) NOT NULL,
	[HouseSitterId] [int] NOT NULL,
	[PreferredLocation] [nvarchar](50) NOT NULL,
	[AccurateRangeStart] [date] NOT NULL,
	[AccurateRangeEnd] [date] NOT NULL,
	[CalendarRangeId] [int] NOT NULL,
 CONSTRAINT [PK_Calendar] PRIMARY KEY CLUSTERED 
(
	[CalendarId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Calendar]  WITH CHECK ADD  CONSTRAINT [FK_Calendar_CalendarRange] FOREIGN KEY([CalendarRangeId])
REFERENCES [dbo].[CalendarRange] ([CalendarRangeId])
GO

ALTER TABLE [dbo].[Calendar] CHECK CONSTRAINT [FK_Calendar_CalendarRange]
GO

ALTER TABLE [dbo].[Calendar]  WITH CHECK ADD  CONSTRAINT [FK_Calendar_HouseSitter] FOREIGN KEY([HouseSitterId])
REFERENCES [dbo].[HouseSitter] ([HouseSitterId])
GO

ALTER TABLE [dbo].[Calendar] CHECK CONSTRAINT [FK_Calendar_HouseSitter]
GO


/****** Object:  Table [dbo].[Owner]    Script Date: 6/29/2013 8:38:21 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Owner](
	[OwnerId] [int] IDENTITY(1,1) NOT NULL,
	[ContacInfoId] [int] NOT NULL,
	[UserId] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Owner] PRIMARY KEY CLUSTERED 
(
	[OwnerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Owner]  WITH CHECK ADD  CONSTRAINT [FK_Owner_ContactInfo] FOREIGN KEY([OwnerId])
REFERENCES [dbo].[ContactInfo] ([ContactInfoId])
GO

ALTER TABLE [dbo].[Owner] CHECK CONSTRAINT [FK_Owner_ContactInfo]
GO

ALTER TABLE [dbo].[Owner]  WITH CHECK ADD  CONSTRAINT [FK_Owner_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO

ALTER TABLE [dbo].[Owner] CHECK CONSTRAINT [FK_Owner_User]
GO


/****** Object:  Table [dbo].[House]    Script Date: 6/29/2013 8:40:28 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[House](
	[HouseId] [int] IDENTITY(1,1) NOT NULL,
	[ContactInfoId] [int] NOT NULL,
	[OwnerId] [int] NOT NULL,
	[Pets] [nvarchar](500) NULL,
	[HasDogs] [bit] NOT NULL,
	[HasCats] [bit] NOT NULL,
	[HasExoticAnimals] [bit] NOT NULL,
	[HouseType] [nvarchar](250) NOT NULL,
	[Rooms] [int] NULL,
	[PreferredAge] [nvarchar](250) NULL,
	[PreferredMarried] [bit] NULL,
	[PreferredGender] [bit] NULL,
	[HouseDescription] [nvarchar](max) NULL,
	[DateAvailableFrom] [date] NOT NULL,
	[DateAvailableTo] [date] NOT NULL,
 CONSTRAINT [PK_House] PRIMARY KEY CLUSTERED 
(
	[HouseId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[House]  WITH CHECK ADD  CONSTRAINT [FK_House_ContactInfo] FOREIGN KEY([ContactInfoId])
REFERENCES [dbo].[ContactInfo] ([ContactInfoId])
GO

ALTER TABLE [dbo].[House] CHECK CONSTRAINT [FK_House_ContactInfo]
GO

ALTER TABLE [dbo].[House]  WITH CHECK ADD  CONSTRAINT [FK_House_Owner] FOREIGN KEY([OwnerId])
REFERENCES [dbo].[Owner] ([OwnerId])
GO

ALTER TABLE [dbo].[House] CHECK CONSTRAINT [FK_House_Owner]
GO

